//MyChart.getInstance(echarts,main).createChart()//初始化入口函数
export default class MyChart {
    constructor(_echart, _ele) {
        this.option = null //当前echarts实例的属性
        this._echart = _echart //引入Echarts
        this._ele = _ele //案例的父元素
        this.myChart = null //当前echarts实例
       
    }
    static getInstance() { //单例模式
        if (!MyChart._instance) {
            console.log(...arguments)
            Object.defineProperty(MyChart, "_instance", {
                value: new MyChart(...arguments)
            })
        }
        return MyChart._instance;
    }
    createChart = () => {
        this.disposeChart() //创建前初始化chart实例，若有，则销毁
        this.myChart = this._echart.init(this._ele)
        this.option={

        }
        this.myChart.setOption(this.option, true)
        
    }
    disposeChart = () => { //初始化chart实例
        if (this.myChart) {
            this.myChart.dispose()
            this.myChart = null
            this.option = null
        }
    }
  
}